#ifndef CHOOSEFRIENDDIALOG_H
#define CHOOSEFRIENDDIALOG_H

#include <QDialog>
#include <QWidget>
#include <QCheckBox>
#include <QLabel>

class ChooseFriendDialog;

///////////////////////////////////////////////
///选择好友窗口中的一个item
///////////////////////////////////////////////
class ChooseFriendItem : public QWidget
{
    Q_OBJECT
public:
    ChooseFriendItem(const QString& userId,const QIcon& avatar,const QString& name,bool isChecked,ChooseFriendDialog* owner);
    QCheckBox* getCheckBox();
    static ChooseFriendItem* copyItem(ChooseFriendItem* item);
    QString getUserId(){return userId;};
private:
    void paintEvent(QPaintEvent* event) override;
    void enterEvent(QEnterEvent* event) override;
    void leaveEvent(QEvent* event) override;

    QString userId;
    QCheckBox* checkBox;
    QPushButton* avatarBtn;
    QLabel* nameLabel;
    ChooseFriendDialog* owner;//就是item所在的ChooseFriendDialog
};



class ChooseFriendDialog : public QDialog
{
    Q_OBJECT
public:
    ChooseFriendDialog(QWidget* parent,const QString& sessionOwnerId);
    void addFriendItem(ChooseFriendItem* item);
    void checkedFriendItem(ChooseFriendItem* item);
    void uncheckedFriendItem(ChooseFriendItem* leftItem,ChooseFriendItem* rightItem);
    void clickCreateSessionBtn();
    QList<QString>* getCreateSessionMemberList();

    QString sessionOwnerId;
    QWidget* leftContainer;
    QWidget* rightContainer;
private:
    //左边是全部的item,右边是选中的item
    void initLeft();
    void initRight();
};

#endif // CHOOSEFRIENDDIALOG_H
